package com.ucn.groupawesome.archgame;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

public class ColorListAdapter extends ArrayAdapter<String>
{
	BrickManager bm;

	public ColorListAdapter(Context context, int simpleListItemMultipleChoice, List<String> objects)
	{
		super(context, simpleListItemMultipleChoice, objects);
		bm = BrickManager.getInstance();
	}

	@Override
	public int getItemViewType(int position)
	{

		String item = getItem(position);

		switch (bm.findBrick(item).getCategory())
		{
			case GREEN:
			{
				return Color.rgb(0, 94, 19);
			}
			case YELLOW:
			{
				return Color.rgb(250, 204, 0);
			}
			case RED:
			{
				return Color.RED;
			}
			default:
			{
				return Color.GRAY;
			}
		}
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		View v = super.getView(position, convertView, parent);

		v.setBackgroundColor(getItemViewType(position));

		return v;

	}
}
